 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DAO.*;
import DTO.*;
import java.awt.Desktop;
import java.util.List;

import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.util.regex.*;

import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;


import java.awt.event.*;
import java.io.File;
import java.io.IOException;

import java.sql.*;
import java.text.SimpleDateFormat;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;

/**
 *
 * @author Luis Olave 10
 */
public class IngresoGarante extends javax.swing.JFrame {

    Connection conexion, conexion2;
    Statement st, st2;
    ResultSet rs, rs2;
    DefaultComboBoxModel modeloCombo6 = new DefaultComboBoxModel(); //region particular
    DefaultComboBoxModel modeloCombo7 = new DefaultComboBoxModel(); // comuna particular
    Connection conexionn, conexion3;
    Statement stt, st3;
    ResultSet rss, rs3;
    DefaultComboBoxModel modeloCombo8 = new DefaultComboBoxModel(); // region trabajo
    DefaultComboBoxModel modeloCombo9 = new DefaultComboBoxModel(); // comuna trabajo 
    usuarioDTO user;
    garantiasDAO reg = new garantiasDAO();

    /**
     * Creates new form IngresoGarante
     */
    public IngresoGarante(usuarioDTO user) {
        initComponents();
        this.user = user;
        btnDireccionArchivo.setVisible(false);
//        cargarItemsComboBoxComunaDireParti();
//        cargarItemsComboBoxComunaDireTrab();
//        cargarItemsComboBoxRegionDireParti();
//        cargarItemsComboBoxRegionDireTrab();
       this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        llenar_region_particular();
        // llenar_region_trabajo();

        this.cmbRegionGara.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg) {
                llenar_comuna_particular((String) cmbRegionGara.getSelectedItem().toString());
            }
        });

        llenar_region_trabajo();
        this.cmbRegionTrabGara.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg) {
                llenar_comuna_trabajo((String) cmbRegionTrabGara.getSelectedItem().toString());
            }
        });


    }

    public void llenar_region_particular() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            /**CAMBIAR PASS A 1234 */
            conexion = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/garantias", "root", "1234");
            st = (Statement) conexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            rs = st.executeQuery("SELECT * FROM region");
            modeloCombo6.addElement("Seleccione");
            cmbRegionGara.setModel(modeloCombo6);
            while (rs.next()) {
                modeloCombo6.addElement(rs.getObject("nom_region"));
                cmbRegionGara.setModel(modeloCombo6);
            }

            st.close();
        } catch (SQLException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void llenar_comuna_particular(String nom_region) {
        this.cmbComunaGara.enable(true);
        this.cmbComunaGara.removeAllItems();
        try {
            Class.forName("com.mysql.jdbc.Driver");
            /**CAMBIAR PASS A 1234 */
            conexion = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/garantias", "root", "1234");
            st = (Statement) conexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            rs = st.executeQuery("SELECT * FROM comuna,region "
                    + "WHERE comuna.id_region=region.id_region "
                    + "AND nom_region='" + nom_region + "'");
            modeloCombo7.addElement("Seleccione");
            cmbComunaGara.setModel(modeloCombo7);
            while (rs.next()) {
                modeloCombo7.addElement(rs.getObject("nom_comuna"));
                cmbComunaGara.setModel(modeloCombo7);
            }

            st.close();
        } catch (SQLException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    ////// DIRECCION TRABAJO ////////////
    public void llenar_region_trabajo() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            /**CAMBIAR PASS A 1234 */
            conexionn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/garantias", "root", "1234");
            stt = (Statement) conexionn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            rss = stt.executeQuery("SELECT * FROM region_lugar_trab");
            modeloCombo8.addElement("Seleccione");
            cmbRegionTrabGara.setModel(modeloCombo8);
            while (rss.next()) {
                modeloCombo8.addElement(rss.getObject("nom_region_trab"));
                cmbRegionTrabGara.setModel(modeloCombo8);
            }

            stt.close();
        } catch (SQLException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void llenar_comuna_trabajo(String nom_region_trab) {
        this.cmbComunaTrabGara.enable(true);
        this.cmbComunaTrabGara.removeAllItems();
        try {
            Class.forName("com.mysql.jdbc.Driver");
            /**CAMBIAR PASS A 1234 */
            conexionn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/garantias", "root", "1234");
            stt = (Statement) conexionn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
            rss = stt.executeQuery("SELECT * FROM comuna_lugar_trab,region_lugar_trab "
                    + "WHERE comuna_lugar_trab.id_region_trab=region_lugar_trab.id_region_trab "
                    + "AND nom_region_trab='" + nom_region_trab + "'");
            modeloCombo9.addElement("Seleccione");
            cmbComunaTrabGara.setModel(modeloCombo9);
            while (rss.next()) {
                modeloCombo9.addElement(rss.getObject("nom_comuna_trab"));
                cmbComunaTrabGara.setModel(modeloCombo9);
            }

            stt.close();
        } catch (SQLException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

//    private void cargarItemsComboBoxComunaDireParti() {
//        List<comunaDTO> ListaComuna = CCComuna.listarItemComuna();
//        if (ListaComuna != null) {
 //            int size = ListaComuna.size();
//            for (int i = 0; i < size; i++) {
//                this.cmbComunaGara.addItem(ListaComuna.get(i));
//            }
//        }
//    }
//
//    private void cargarItemsComboBoxComunaDireTrab() {
//        List<comunaDTO> ListaComuna = CCComuna.listarItemComuna();
//        if (ListaComuna != null) {
//            int size = ListaComuna.size();
//            for (int i = 0; i < size; i++) {
//                this.cmbComunaTrabGara.addItem(ListaComuna.get(i));
//            }
//        }
//    }
//
//    private void cargarItemsComboBoxRegionDireParti() {
//        List<regionDTO> ListaRegion = CCRegion.listarRegion();
//        if (ListaRegion != null) {
//            int size = ListaRegion.size();
//            for (int i = 0; i < size; i++) {
//                this.cmbRegionGara.addItem(ListaRegion.get(i));
//            }
//        }
//    }
//
//    private void cargarItemsComboBoxRegionDireTrab() {
//        List<regionDTO> ListaRegion = CCRegion.listarRegion();
//        if (ListaRegion != null) {
//            int size = ListaRegion.size();
//            for (int i = 0; i < size; i++) {
//                this.cmbRegionTrabGara.addItem(ListaRegion.get(i));
//            }
//        }
//    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        pnlPrincipal = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        pnlIngresarDatosGarante = new javax.swing.JPanel();
        pnlDatosPersonales = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtApellPatGar = new javax.swing.JTextField();
        txtApellMatGar = new javax.swing.JTextField();
        txtRutGar = new javax.swing.JTextField();
        txtNomGara = new javax.swing.JTextField();
        rdMasculino = new javax.swing.JRadioButton();
        rdFemenino = new javax.swing.JRadioButton();
        jcFecha_nac_gara = new com.toedter.calendar.JDateChooser();
        btnBuscarGaranteExistente = new javax.swing.JButton();
        pnlDireParticular = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        txtDeptoGara = new javax.swing.JTextField();
        txtNumeroGara = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtCalleGara = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtPoblaGara = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        cmbRegionGara = new javax.swing.JComboBox();
        cmbComunaGara = new javax.swing.JComboBox();
        pnlNumContacto = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtTelParGar = new javax.swing.JTextField();
        txtTelTrabGara = new javax.swing.JTextField();
        txtTelMovGara = new javax.swing.JTextField();
        txtFaxGara = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        txtMailGara = new javax.swing.JTextField();
        pnlDireTrabajo = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        txtNomEmprGara = new javax.swing.JTextField();
        txtNumOfGara = new javax.swing.JTextField();
        txtNumTrabGara = new javax.swing.JTextField();
        txtCalleTrabGara = new javax.swing.JTextField();
        cmbRegionTrabGara = new javax.swing.JComboBox();
        cmbComunaTrabGara = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        btnDireccionArchivo = new javax.swing.JButton();
        btnGrabar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnMenuPrincipal = new javax.swing.JButton();
        btnExportarGarante = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("INGRESO GARANTES");
        setResizable(false);

        pnlPrincipal.setPreferredSize(new java.awt.Dimension(700, 610));

        jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
        jLabel1.setText("INGRESO DE GARANTES");

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGE/logo.JPG"))); // NOI18N

        pnlIngresarDatosGarante.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INGRESAR DATOS GARANTE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 12), java.awt.Color.blue)); // NOI18N

        pnlDatosPersonales.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS PERSONALES", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel3.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel3.setText("RUT");

        jLabel4.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel4.setText("APELLIDO PATERNO");

        jLabel5.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel5.setText("APELLIDO MATERNO");

        jLabel6.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel6.setText("NOMBRE");

        jLabel7.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel7.setText("FECHA NACIMIENTO");

        jLabel8.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel8.setText("SEXO");

        txtApellPatGar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtApellPatGarKeyReleased(evt);
            }
        });

        txtApellMatGar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtApellMatGarKeyReleased(evt);
            }
        });

        txtNomGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNomGaraKeyReleased(evt);
            }
        });

        buttonGroup1.add(rdMasculino);
        rdMasculino.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        rdMasculino.setSelected(true);
        rdMasculino.setText("MASCULINO");

        buttonGroup1.add(rdFemenino);
        rdFemenino.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        rdFemenino.setText("FEMENINO");

        btnBuscarGaranteExistente.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnBuscarGaranteExistente.setText("Buscar");
        btnBuscarGaranteExistente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarGaranteExistenteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlDatosPersonalesLayout = new javax.swing.GroupLayout(pnlDatosPersonales);
        pnlDatosPersonales.setLayout(pnlDatosPersonalesLayout);
        pnlDatosPersonalesLayout.setHorizontalGroup(
            pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                        .addComponent(txtRutGar, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBuscarGaranteExistente))
                    .addComponent(txtApellPatGar, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtApellMatGar, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                        .addComponent(rdMasculino)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rdFemenino))
                    .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jcFecha_nac_gara, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                        .addComponent(txtNomGara, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        pnlDatosPersonalesLayout.setVerticalGroup(
            pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPersonalesLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtRutGar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBuscarGaranteExistente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtApellPatGar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtApellMatGar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNomGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcFecha_nac_gara, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rdMasculino)
                    .addComponent(rdFemenino))
                .addContainerGap())
        );

        pnlDireParticular.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DIRECCIÓN PARTICULAR", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel11.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel11.setText("DEPTO.");

        txtDeptoGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtDeptoGaraKeyReleased(evt);
            }
        });

        txtNumeroGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNumeroGaraKeyReleased(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel10.setText("NÚMERO");

        jLabel9.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel9.setText("CALLE / AVENIDA");

        txtCalleGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtCalleGaraKeyReleased(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel13.setText("POBLACIÓN / VILLA");

        txtPoblaGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtPoblaGaraKeyReleased(evt);
            }
        });

        jLabel23.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel23.setText("REGIÓN");

        jLabel24.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel24.setText("COMUNA");

        cmbRegionGara.setEditable(true);
        cmbRegionGara.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
        cmbRegionGara.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));
        cmbRegionGara.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbRegionGaraActionPerformed(evt);
            }
        });

        cmbComunaGara.setEditable(true);
        cmbComunaGara.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
        cmbComunaGara.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));
        cmbComunaGara.setEnabled(false);
        cmbComunaGara.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbComunaGaraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlDireParticularLayout = new javax.swing.GroupLayout(pnlDireParticular);
        pnlDireParticular.setLayout(pnlDireParticularLayout);
        pnlDireParticularLayout.setHorizontalGroup(
            pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDireParticularLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(13, 13, 13))
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(74, 74, 74))
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(69, 69, 69))
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(58, 58, 58)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cmbRegionGara, javax.swing.GroupLayout.Alignment.LEADING, 0, 123, Short.MAX_VALUE)
                    .addComponent(txtPoblaGara, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDeptoGara, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtCalleGara, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbComunaGara, 0, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtNumeroGara, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );
        pnlDireParticularLayout.setVerticalGroup(
            pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDireParticularLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtCalleGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(txtNumeroGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(cmbRegionGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmbComunaGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlDireParticularLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(txtDeptoGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlDireParticularLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(txtPoblaGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel24)))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        pnlNumContacto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CONTACTO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel14.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel14.setText("TEL. PARTICULAR");

        jLabel15.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel15.setText("TEL. TRABAJO ");

        jLabel16.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel16.setText("TEL. MOVIL");

        jLabel17.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel17.setText("FAX");

        txtTelParGar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTelParGarKeyReleased(evt);
            }
        });

        txtTelTrabGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTelTrabGaraKeyReleased(evt);
            }
        });

        txtTelMovGara.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelMovGaraActionPerformed(evt);
            }
        });
        txtTelMovGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtTelMovGaraKeyReleased(evt);
            }
        });

        txtFaxGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtFaxGaraKeyReleased(evt);
            }
        });

        jLabel26.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel26.setText("MAIL");

        javax.swing.GroupLayout pnlNumContactoLayout = new javax.swing.GroupLayout(pnlNumContacto);
        pnlNumContacto.setLayout(pnlNumContactoLayout);
        pnlNumContactoLayout.setHorizontalGroup(
            pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNumContactoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(35, 35, 35))
                    .addGroup(pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(75, 75, 75))
                    .addGroup(pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(68, 68, 68))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                        .addGap(18, 18, 18)))
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtMailGara, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                    .addComponent(txtTelParGar)
                    .addComponent(txtTelTrabGara)
                    .addComponent(txtTelMovGara)
                    .addComponent(txtFaxGara))
                .addGap(85, 85, 85))
        );
        pnlNumContactoLayout.setVerticalGroup(
            pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlNumContactoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(txtTelParGar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlNumContactoLayout.createSequentialGroup()
                        .addGap(0, 11, Short.MAX_VALUE)
                        .addComponent(txtTelTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlNumContactoLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtTelMovGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFaxGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlNumContactoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(txtMailGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        pnlDireTrabajo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DIRECCIÓN TRABAJO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Century Gothic", 1, 10), java.awt.Color.blue)); // NOI18N

        jLabel18.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel18.setText("CALLE / AVENIDA");

        jLabel19.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel19.setText("NÚMERO");

        jLabel20.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel20.setText("NÚMERO OFICINA");

        jLabel21.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel21.setText("REGIÓN");

        jLabel22.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel22.setText("COMUNA");

        jLabel25.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabel25.setText("NOMBRE EMPRESA");

        txtNomEmprGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNomEmprGaraKeyReleased(evt);
            }
        });

        txtNumOfGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNumOfGaraKeyReleased(evt);
            }
        });

        txtNumTrabGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtNumTrabGaraKeyReleased(evt);
            }
        });

        txtCalleTrabGara.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtCalleTrabGaraKeyReleased(evt);
            }
        });

        cmbRegionTrabGara.setEditable(true);
        cmbRegionTrabGara.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
        cmbRegionTrabGara.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));

        cmbComunaTrabGara.setEditable(true);
        cmbComunaTrabGara.setFont(new java.awt.Font("Century Gothic", 0, 10)); // NOI18N
        cmbComunaTrabGara.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));
        cmbComunaTrabGara.setEnabled(false);

        javax.swing.GroupLayout pnlDireTrabajoLayout = new javax.swing.GroupLayout(pnlDireTrabajo);
        pnlDireTrabajo.setLayout(pnlDireTrabajoLayout);
        pnlDireTrabajoLayout.setHorizontalGroup(
            pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDireTrabajoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel25, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                    .addComponent(jLabel20, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDireTrabajoLayout.createSequentialGroup()
                        .addComponent(txtCalleTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNumTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtNumOfGara, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNomEmprGara, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbRegionTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbComunaTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDireTrabajoLayout.setVerticalGroup(
            pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDireTrabajoLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(txtCalleTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(txtNumTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(txtNumOfGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNomEmprGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbRegionTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDireTrabajoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(cmbComunaTrabGara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btnDireccionArchivo.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnDireccionArchivo.setText("BUSCAR GARANTE EN EXCEL");
        btnDireccionArchivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDireccionArchivoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnDireccionArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 122, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnDireccionArchivo)
                .addGap(59, 59, 59))
        );

        javax.swing.GroupLayout pnlIngresarDatosGaranteLayout = new javax.swing.GroupLayout(pnlIngresarDatosGarante);
        pnlIngresarDatosGarante.setLayout(pnlIngresarDatosGaranteLayout);
        pnlIngresarDatosGaranteLayout.setHorizontalGroup(
            pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlDatosPersonales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlDireParticular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlDireTrabajo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlNumContacto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlIngresarDatosGaranteLayout.setVerticalGroup(
            pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlIngresarDatosGaranteLayout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(pnlNumContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(pnlDatosPersonales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlIngresarDatosGaranteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlDireTrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlDireParticular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnGrabar.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnGrabar.setText("GRABAR");
        btnGrabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarActionPerformed(evt);
            }
        });

        btnCancelar.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnCancelar.setText("CANCELAR");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnMenuPrincipal.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnMenuPrincipal.setText("MENÚ PRINCIPAL >>");
        btnMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMenuPrincipalActionPerformed(evt);
            }
        });

        btnExportarGarante.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        btnExportarGarante.setText("EXPORTAR");
        btnExportarGarante.setMaximumSize(new java.awt.Dimension(85, 25));
        btnExportarGarante.setMinimumSize(new java.awt.Dimension(85, 25));
        btnExportarGarante.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExportarGaranteActionPerformed(evt);
            }
        });

        jLabel12.setText("MENÚ PRINCIPAL\\INGRESO DE GARANTES");

        javax.swing.GroupLayout pnlPrincipalLayout = new javax.swing.GroupLayout(pnlPrincipal);
        pnlPrincipal.setLayout(pnlPrincipalLayout);
        pnlPrincipalLayout.setHorizontalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addGap(209, 209, 209)
                .addComponent(btnGrabar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnExportarGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnMenuPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(144, 144, 144))
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlIngresarDatosGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                                .addGap(155, 155, 155)
                                .addComponent(jLabel1))
                            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel12)))))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        pnlPrincipalLayout.setVerticalGroup(
            pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(pnlPrincipalLayout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jLabel1))
                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlIngresarDatosGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addGroup(pnlPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnGrabar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnMenuPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnExportarGarante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22))
        );

        jScrollPane1.setViewportView(pnlPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 870, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 709, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        setSize(new java.awt.Dimension(886, 747));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMenuPrincipalActionPerformed
        MenuPrincipal venMenuPrincipal = new MenuPrincipal(user);
        venMenuPrincipal.setVisible(true);
        IngresoGarante.this.dispose();
    }//GEN-LAST:event_btnMenuPrincipalActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        this.txtApellMatGar.setText("");
        this.txtApellPatGar.setText("");
        this.txtCalleGara.setText("");
        this.txtCalleTrabGara.setText("");
        this.txtDeptoGara.setText("");
        this.txtFaxGara.setText("");
        this.txtMailGara.setText("");
        this.txtNomEmprGara.setText("");
        this.txtNomGara.setText("");
        this.txtNumOfGara.setText("");
        this.txtNumTrabGara.setText("");
        this.txtPoblaGara.setText("");
        this.txtRutGar.setText("");
        this.txtTelMovGara.setText("");
        this.txtTelParGar.setText("");
        this.txtTelTrabGara.setText("");
        this.txtNumeroGara.setText("");
        this.rdMasculino.setSelected(true);
        this.rdFemenino.setSelected(false);
        this.cmbComunaGara.setSelectedItem("Seleccione");
        this.cmbComunaTrabGara.setSelectedItem("Seleccione");
        this.cmbRegionGara.setSelectedItem("Seleccione");
        this.cmbRegionTrabGara.setSelectedItem("Seleccione");
        this.jcFecha_nac_gara.setCalendar(null);
        this.btnGrabar.setVisible(true);
        this.btnBuscarGaranteExistente.setVisible(true);

    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnGrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarActionPerformed
        garanteDTO garante = new garanteDTO();
        if (this.txtRutGar.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Rut");
        }// else if (this.txtRutGar.getText().matches("^[0-9]+-([kK0-9])+$")) 
       // {
         //   javax.swing.JOptionPane.showMessageDialog(this, "Ingrese un Rut valido");
          //  this.txtRutGar.setText(" ");
       /* }*/ else if (this.txtApellPatGar.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Apellido Paterno");
        } else if (this.txtApellMatGar.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Apellido Materno");
        } else if (this.txtNomGara.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Nombre");
        } else if (this.txtCalleGara.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Calle / Avenida Particular");
        } else if (this.txtNumeroGara.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Número Particular");
        } /*else if (this.txtMailGara.getText().length() == 0) // validamos campos vacios
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese Ingrese E-Mail");
          } else if(!this.txtMailGara.getText().matches("^[a-zA-Z0-9_-]{2,}@[a-zA-Z0-9_-]{2,}\\.[a-zA-Z]{2,4}(\\.[a-zA-Z]{2,4})?$")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese e-mail valido");
            this.txtMailGara.setText("");
        } */else {
            garante.setRut_gara(this.txtRutGar.getText().trim());
            garante.setApell_paterno_gara(this.txtApellPatGar.getText().trim());
            garante.setApell_materno_gara(this.txtApellMatGar.getText().trim());
            garante.setNombre_gara(this.txtNomGara.getText());
            garante.setFecha_nac_gara(new SimpleDateFormat("dd/MM/yyyy").format(jcFecha_nac_gara.getDate()));
            garante.setEstado("true");
            String sexo = "";
            if (this.rdMasculino.isSelected()) {
                sexo = "Masculino";
            }
            if (this.rdFemenino.isSelected()) {
                sexo = "Femenino";
            }
            garante.setSexo_gara(sexo);

            garante.setCalle_gara(this.txtCalleGara.getText());
            garante.setNum_gara(Integer.parseInt(this.txtNumeroGara.getText().trim()));
            if(!txtDeptoGara.getText().equals(""))
            {
                garante.setDepto_gara(this.txtDeptoGara.getText().trim());
            }
            if(!txtPoblaGara.getText().equals(""))
            {
               garante.setPobla_gara(this.txtPoblaGara.getText()); 
            }
            garante.setReg_gara(this.cmbRegionGara.getSelectedItem().toString());
            garante.setComu_gara(this.cmbComunaGara.getSelectedItem().toString());
            if(!txtTelParGar.getText().equals(""))
            {
                garante.setTel_part_gara(Integer.parseInt(this.txtTelParGar.getText())); 
            }
            if(!txtTelTrabGara.getText().equals(""))
            {
                garante.setTel_trab_gara(Integer.parseInt(this.txtTelTrabGara.getText().trim()));
            }
            if(!txtTelMovGara.getText().equals(""))
            {
                garante.setTel_mov_gara(Integer.parseInt(this.txtTelMovGara.getText().trim()));
            }
            if(!txtFaxGara.getText().equals(""))
            {
                garante.setFax_gara(Integer.parseInt(this.txtFaxGara.getText().trim())); 
            }
            if(!txtFaxGara.getText().equals(""))
            {
                garante.setE_mail(this.txtMailGara.getText().trim());  
            }
            if(!txtCalleTrabGara.getText().equals(""))
            {
                garante.setCalle_trab_gara(this.txtCalleTrabGara.getText());
            }
            if(!txtNumTrabGara.getText().equals(""))
            {
                garante.setNum_trab_gara(Integer.parseInt(this.txtNumTrabGara.getText().trim()));
            }
            if(!txtNumOfGara.getText().equals(""))
            {
                garante.setNum_ofi_gara(this.txtNumOfGara.getText().trim());
            }
            if(!txtNomEmprGara.getText().equals(""))
            {
                garante.setNom_emp_gara(this.txtNomEmprGara.getText());
            }
            if(!cmbRegionTrabGara.getSelectedItem().equals("Seleccione"))
            {
                garante.setReg_emp_gara(this.cmbRegionTrabGara.getSelectedItem().toString());
            }
            if(!cmbComunaTrabGara.getSelectedItem().equals("Seleccione"))
            {
                garante.setComu_emp_gara(this.cmbComunaTrabGara.getSelectedItem().toString());
            }
            
            reg.creacionGarante(garante, user);
            javax.swing.JOptionPane.showMessageDialog(this, "Garante almacenado con Exito");
        }


    }//GEN-LAST:event_btnGrabarActionPerformed

    private void txtApellPatGarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellPatGarKeyReleased
        if (!this.txtApellPatGar.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtApellPatGar.setText("");
        }
    }//GEN-LAST:event_txtApellPatGarKeyReleased

    private void txtApellMatGarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellMatGarKeyReleased
        if (!this.txtApellMatGar.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtApellMatGar.setText("");
        }
    }//GEN-LAST:event_txtApellMatGarKeyReleased

    private void txtNomGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNomGaraKeyReleased
        if (!this.txtNomGara.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtNomGara.setText("");
        }
    }//GEN-LAST:event_txtNomGaraKeyReleased

    private void txtCalleGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCalleGaraKeyReleased
        if (!this.txtCalleGara.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtCalleGara.setText("");
        }
    }//GEN-LAST:event_txtCalleGaraKeyReleased

    private void txtNumeroGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumeroGaraKeyReleased
        if (!this.txtNumeroGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtNumeroGara.setText("");
        }
    }//GEN-LAST:event_txtNumeroGaraKeyReleased

    private void txtDeptoGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDeptoGaraKeyReleased
        if (!this.txtDeptoGara.getText().matches("[ 0-9 A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras y/o números ");
            this.txtDeptoGara.setText("");
        }
    }//GEN-LAST:event_txtDeptoGaraKeyReleased

    private void txtPoblaGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPoblaGaraKeyReleased
        if (!this.txtPoblaGara.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtPoblaGara.setText("");
        }
    }//GEN-LAST:event_txtPoblaGaraKeyReleased

    private void txtTelParGarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelParGarKeyReleased
        if (!this.txtTelParGar.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtTelParGar.setText("");
        }
    }//GEN-LAST:event_txtTelParGarKeyReleased

    private void txtTelTrabGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelTrabGaraKeyReleased
        if (!this.txtTelTrabGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtTelTrabGara.setText("");
        }
    }//GEN-LAST:event_txtTelTrabGaraKeyReleased

    private void txtTelMovGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelMovGaraKeyReleased
        if (!this.txtTelMovGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtTelMovGara.setText("");
        }
    }//GEN-LAST:event_txtTelMovGaraKeyReleased

    private void txtFaxGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtFaxGaraKeyReleased
        if (!this.txtFaxGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtFaxGara.setText("");
        }
    }//GEN-LAST:event_txtFaxGaraKeyReleased

    private void txtCalleTrabGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCalleTrabGaraKeyReleased
        if (!this.txtCalleTrabGara.getText().matches("[ A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras");
            this.txtCalleTrabGara.setText("");
        }
    }//GEN-LAST:event_txtCalleTrabGaraKeyReleased

    private void txtNumTrabGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumTrabGaraKeyReleased
        if (!this.txtNumTrabGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtNumTrabGara.setText("");
        }
    }//GEN-LAST:event_txtNumTrabGaraKeyReleased

    private void txtNumOfGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNumOfGaraKeyReleased
        if (!this.txtNumOfGara.getText().matches("[ 0-9]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo números");
            this.txtNumOfGara.setText("");
        }
    }//GEN-LAST:event_txtNumOfGaraKeyReleased

    private void txtNomEmprGaraKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNomEmprGaraKeyReleased
        if (!this.txtNomEmprGara.getText().matches("[ 0-9 A-Za-z Ññáéíóú]*")) // expresiones regulares para validar
        {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese solo letras y/o números ");
            this.txtNomEmprGara.setText("");
        }
    }//GEN-LAST:event_txtNomEmprGaraKeyReleased

    private void btnExportarGaranteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarGaranteActionPerformed
        String rut = this.txtRutGar.getText().trim();
        reg.exportarGarante(rut);
        javax.swing.JOptionPane.showMessageDialog(this, "Exportación realizada con exito");
        File file = new File("C:/export_garante.csv");
        try {
            Desktop.getDesktop().open(file);
        } catch (IOException ex) {
            Logger.getLogger(IngresoGarante.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnExportarGaranteActionPerformed

    private void cmbRegionGaraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbRegionGaraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbRegionGaraActionPerformed

    private void cmbComunaGaraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbComunaGaraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbComunaGaraActionPerformed

    private void txtTelMovGaraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelMovGaraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTelMovGaraActionPerformed

    private void btnBuscarGaranteExistenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarGaranteExistenteActionPerformed
try {
    if(ValidarRutDAO.validarRut(this.txtRutGar.getText().toUpperCase()))
           {
          javax.swing.JOptionPane.showMessageDialog(this, "Rut valido");
        String buscarPorRut = txtRutGar.getText().toString().trim();
        if(txtRutGar.getText().length()>0){           
        garanteDTO garante = reg.buscarPorRut(this.txtRutGar.getText().trim());
        
        //this.txtRutGar.setText(garante.getRut_gara());
        this.txtApellPatGar.setText(garante.getApell_paterno_gara());
        this.txtApellMatGar.setText(garante.getApell_materno_gara());
        this.txtNomGara.setText(garante.getNombre_gara());
        Date aux = DTO.ConversionFechas.convertToDate(garante.getFecha_nac_gara());
            this.jcFecha_nac_gara.setDate(aux);    
        if(garante.getSexo_gara().equalsIgnoreCase("Masculino")){
                rdMasculino.setSelected(true);
            }else{
                rdFemenino.setSelected(true);
            }        
        this.txtCalleGara.setText(garante.getCalle_gara());
        this.txtNumeroGara.setText(String.valueOf(garante.getNum_gara()));
        this.txtDeptoGara.setText(garante.getDepto_gara());
        this.txtPoblaGara.setText(garante.getPobla_gara()); 
        this.cmbRegionGara.setSelectedItem(garante.getReg_gara());
        this.cmbComunaGara.setSelectedItem(garante.getComu_gara());     
        this.txtTelParGar.setText(String.valueOf(garante.getTel_part_gara()));
        this.txtTelTrabGara.setText(String.valueOf(garante.getTel_trab_gara()));      
        this.txtTelMovGara.setText(String.valueOf(garante.getTel_mov_gara()));
        this.txtMailGara.setText(garante.getE_mail());
        
        this.txtCalleTrabGara.setText(garante.getCalle_trab_gara());               
        this.txtNumTrabGara.setText(String.valueOf(garante.getNum_trab_gara()));
        this.txtNumOfGara.setText(String.valueOf(garante.getNum_ofi_gara()));
        this.txtNomEmprGara.setText(garante.getNom_emp_gara());
        this.cmbRegionTrabGara.setSelectedItem(garante.getReg_emp_gara());
        this.cmbComunaTrabGara.setSelectedItem(garante.getComu_emp_gara());
        this.btnGrabar.setVisible(false);
        javax.swing.JOptionPane.showMessageDialog(this,"Cliente ya existe como garante");
        }
        else{
            javax.swing.JOptionPane.showMessageDialog(this,"debe ingresar un rut");
        }
            }else{
            javax.swing.JOptionPane.showMessageDialog(this, "Rut invalido");
                  }} catch (Exception e) { 
     
        txtApellPatGar.setText(null);
        txtApellMatGar.setText(null);
        txtNomGara.setText(null);
        jcFecha_nac_gara.setDate(null);
        rdMasculino.setSelected(true);       
        txtCalleGara.setText(null);
        txtNumeroGara.setText(null);
        txtDeptoGara.setText(null);
        txtPoblaGara.setText(null);       
        cmbRegionGara.setSelectedItem("Seleccione");
        cmbComunaGara.setSelectedItem("Seleccione");       
        txtTelParGar.setText(null);
        txtTelTrabGara.setText(null);
        txtTelMovGara.setText(null);
        txtFaxGara.setText(null);
        txtMailGara.setText(null);
        txtCalleTrabGara.setText(null);
        txtNumTrabGara.setText(null);
        txtNumOfGara.setText(null);
        txtNomEmprGara.setText(null);
        cmbRegionTrabGara.setSelectedItem("Seleccione");
        cmbComunaTrabGara.setSelectedItem("Seleccione"); 
        this.btnGrabar.setVisible(true);
        
        javax.swing.JOptionPane.showMessageDialog(this,"El rut ingresado no existe, revise los registros del banco");
        btnDireccionArchivo.setVisible(true);
        }      
    }//GEN-LAST:event_btnBuscarGaranteExistenteActionPerformed

    private void btnDireccionArchivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDireccionArchivoActionPerformed
        LectorExcel le = new LectorExcel();
        try {
            if(ValidarRutDAO.validarRut(this.txtRutGar.getText().toUpperCase()))
           {
          javax.swing.JOptionPane.showMessageDialog(this, "Rut valido");
        if(txtRutGar.getText().length()<1)
        {
            javax.swing.JOptionPane.showMessageDialog(this,"ingresar un rut");
        }    
        else{                 
        le.Probar(txtRutGar.getText());
        
        //txtRutGar.setText(le.gar.getRut_gara().trim());
        txtApellPatGar.setText(le.gar.getApell_paterno_gara().trim());
        txtApellMatGar.setText(le.gar.getApell_materno_gara().trim());
        txtNomGara.setText(le.gar.getNombre_gara().trim());
        Date aux = DTO.ConversionFechas.convertToDate(le.gar.getFecha_nac_gara().trim());
        jcFecha_nac_gara.setDate(aux);
        if (le.gar.getSexo_gara().equalsIgnoreCase("Masculino")||le.gar.getSexo_gara().equalsIgnoreCase("masculino")) {
                    rdMasculino.setSelected(true);
                } else {
                    rdFemenino.setSelected(true);
                }
        txtCalleGara.setText(le.gar.getCalle_gara().trim());
        txtNumeroGara.setText(Integer.toString(le.gar.getNum_gara()));
        txtDeptoGara.setText(le.gar.getDepto_gara().trim());
        txtPoblaGara.setText(le.gar.getPobla_gara().trim());       
        cmbRegionGara.setSelectedItem(le.gar.getReg_gara().trim());
        cmbComunaGara.setSelectedItem(le.gar.getComu_gara());       
        txtTelParGar.setText(Integer.toString(le.gar.getTel_part_gara()));
        txtTelTrabGara.setText(Integer.toString(le.gar.getTel_trab_gara()));
        txtTelMovGara.setText(Integer.toString(le.gar.getTel_mov_gara()));
        txtFaxGara.setText(Integer.toString(le.gar.getFax_gara()));
        txtMailGara.setText(le.gar.getE_mail().trim());
        txtCalleTrabGara.setText(le.gar.getCalle_trab_gara().trim());
        txtNumTrabGara.setText(Integer.toString(le.gar.getNum_trab_gara()));
        txtNumOfGara.setText(le.gar.getNum_ofi_gara());
        txtNomEmprGara.setText(le.gar.getNom_emp_gara().trim());
        cmbRegionTrabGara.setSelectedItem(le.gar.getReg_emp_gara());
        cmbComunaTrabGara.setSelectedItem(le.gar.getComu_emp_gara());  
        this.btnGrabar.setVisible(true);
        
        }
        }else{
                javax.swing.JOptionPane.showMessageDialog(this, "Rut invalido");
            }
            }catch (Exception ex) {
            
        txtApellPatGar.setText(null);
        txtApellMatGar.setText(null);
        txtNomGara.setText(null);
        jcFecha_nac_gara.setDate(null);
        rdMasculino.setSelected(true);       
        txtCalleGara.setText(null);
        txtNumeroGara.setText(null);
        txtDeptoGara.setText(null);
        txtPoblaGara.setText(null);       
        cmbRegionGara.setSelectedItem("Seleccione");
        cmbComunaGara.setSelectedItem("Seleccione");       
        txtTelParGar.setText(null);
        txtTelTrabGara.setText(null);
        txtTelMovGara.setText(null);
        txtFaxGara.setText(null);
        txtMailGara.setText(null);
        txtCalleTrabGara.setText(null);
        txtNumTrabGara.setText(null);
        txtNumOfGara.setText(null);
        txtNomEmprGara.setText(null);
        cmbRegionTrabGara.setSelectedItem("Seleccione");
        cmbComunaTrabGara.setSelectedItem("Seleccione"); 
        
        javax.swing.JOptionPane.showMessageDialog(this,"cliente no existe en los registros");
        }
    }//GEN-LAST:event_btnDireccionArchivoActionPerformed
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /*
//         * Set the Nimbus look and feel
//         */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /*
//         * If Nimbus (introduced in Java SE 6) is not available, stay with the
//         * default look and feel. For details see
//         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(IngresoGarante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(IngresoGarante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(IngresoGarante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(IngresoGarante.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /*
//         * Create and display the form
//         */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new IngresoGarante().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarGaranteExistente;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnDireccionArchivo;
    private javax.swing.JButton btnExportarGarante;
    private javax.swing.JButton btnGrabar;
    private javax.swing.JButton btnMenuPrincipal;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cmbComunaGara;
    private javax.swing.JComboBox cmbComunaTrabGara;
    private javax.swing.JComboBox cmbRegionGara;
    private javax.swing.JComboBox cmbRegionTrabGara;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private com.toedter.calendar.JDateChooser jcFecha_nac_gara;
    private javax.swing.JPanel pnlDatosPersonales;
    private javax.swing.JPanel pnlDireParticular;
    private javax.swing.JPanel pnlDireTrabajo;
    private javax.swing.JPanel pnlIngresarDatosGarante;
    private javax.swing.JPanel pnlNumContacto;
    private javax.swing.JPanel pnlPrincipal;
    private javax.swing.JRadioButton rdFemenino;
    private javax.swing.JRadioButton rdMasculino;
    private javax.swing.JTextField txtApellMatGar;
    private javax.swing.JTextField txtApellPatGar;
    private javax.swing.JTextField txtCalleGara;
    private javax.swing.JTextField txtCalleTrabGara;
    private javax.swing.JTextField txtDeptoGara;
    private javax.swing.JTextField txtFaxGara;
    private javax.swing.JTextField txtMailGara;
    private javax.swing.JTextField txtNomEmprGara;
    private javax.swing.JTextField txtNomGara;
    private javax.swing.JTextField txtNumOfGara;
    private javax.swing.JTextField txtNumTrabGara;
    private javax.swing.JTextField txtNumeroGara;
    private javax.swing.JTextField txtPoblaGara;
    private javax.swing.JTextField txtRutGar;
    private javax.swing.JTextField txtTelMovGara;
    private javax.swing.JTextField txtTelParGar;
    private javax.swing.JTextField txtTelTrabGara;
    // End of variables declaration//GEN-END:variables

}
